<?
    header('Content-type: text/html; charset=utf-8');
    $error = 0;
    $errormessage = '';
    if (isset($_GET['error'])) {
        $error = $_GET['error'];
    }
    if ($error != '0') {
        $error = 1;
        $errormessage = 'test error message';
    }
    if (isset($_GET['email'])) {
        $email = $_GET['email'];
    }
    $connection = mysql_connect ('localhost', 'zorik_if039', '9731')
    or die ('Unable to connect!');
    mysql_select_db('zorik_if039') or die (mysql_error());
    mysql_query("set character_set_client='utf8'"); 
    mysql_query("set character_set_server='utf8'"); 
    mysql_query("set character_set_results='utf8'"); 
    mysql_query("set collation_connection='utf8_unicode_ci'");
    $query = "SELECT * FROM user where email='".$email."'";
    $res = mysql_query($query) or die(mysql_error());
    $rows = array();
    while($r = mysql_fetch_assoc($res)) {
        $rows[] = $r;
    }
    if ($error == 0) {
        $emailList = (object) array('error' => $error, 'errormessage' => $errormessage, 'data' => $rows);
    } else {
        $emailList = (object) array('error' => $error, 'errormessage' => $errormessage, 'data' => '');
    }
    echo json_encode($emailList);
    mysql_close($connection);
?>